package java2d.game.sudoku;

import com.formdev.flatlaf.FlatClientProperties;
import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.fonts.roboto_mono.FlatRobotoMonoFont;
import com.formdev.flatlaf.themes.FlatMacDarkLaf;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.image.BufferedImage;
import java.io.IOException;

public class SudokuApp
{
    public static void main(String[] args) throws IOException
    {
        BufferedImage icon = ImageIO.read(SudokuApp.class.getResource("/sudoku.png"));

        FlatRobotoMonoFont.install();
        FlatLaf.setPreferredMonospacedFontFamily(FlatRobotoMonoFont.FAMILY);
        FlatMacDarkLaf.setup();

        SwingUtilities.invokeLater(() -> {
            JFrame frame = new JFrame("摇摆数独");
            frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            frame.setIconImage(icon);

            SudokuBoard board = new SudokuBoard();
            frame.getRootPane().putClientProperty(FlatClientProperties.FULL_WINDOW_CONTENT, true);
            frame.getContentPane().add(board);
            frame.pack();

            board.requestFocus();

            frame.setLocationRelativeTo(null);
            frame.setResizable(false);
            frame.setVisible(true);

            JOptionPane.showMessageDialog(frame,
                                          "F2~F4开始新游戏，F1查看操作说明。",
                                          "游戏提示",
                                          JOptionPane.INFORMATION_MESSAGE);
        });
    }
}
